package org.jtao.gbsubject.domain;

import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
 * 学院实体
 */
@ApiModel(description = "学院实体")
@Entity
@Table(name = "college")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class College implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Excel(name = "所在学院" )
    @Column(name = "name")
    private String name;

   /* @ManyToMany
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    @JoinTable(name = "subject_college",
        joinColumns = @JoinColumn(name="subjects_id", referencedColumnName="id"),
        inverseJoinColumns = @JoinColumn(name="colleges_id", referencedColumnName="id"))
    private Set<Subject> subjects =new HashSet<>();*/

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    /*public Set<Subject> getSubjects() {
        return subjects;
    }*/

    /*public College subjects(Set<Subject> subjects ){
        this.subjects=subjects;
        return this;
    }*/

    /*public void setSubjects(Set<Subject> subjects) {
        this.subjects = subjects;
    }*/

    /*public College addSubject(Subject subject){
        this.subjects.add(subject);
        return this;
    }*/

   /* public College removeSubject(Subject subject){
        this.subjects.remove(subject);
        return this;
    }*/

    public String getName() {
        return name;
    }

    public College name(String name) {
        this.name = name;
        return this;
    }

    public void setName(String name) {
        this.name = name;
    }
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        College college = (College) o;
        if (college.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), college.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "College{" +
            "id=" + getId() +
            ", name='" + getName() + "'" +
            "}";
    }
}
